<template>
    <div class="newsinfo-container">
        <!-- 标题和子标题 -->
        <h3 class="title">{{newsList.title}}</h3>
        <p class="subtitle">
            <span>发表时间:{{newsList.time}}</span>
            <span>点击:{{newsList.click}}次</span>
        </p>
        <hr>
        <!-- 内容区域 -->
        <div class="content" v-html="newsInfo.article">
           
        </div>
        <!-- 评论区域 -->
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
//导入评论子组件
import comment from '../subcomponents/comment.vue'
    import {
        Toast
    } from 'mint-ui'
    export default {
        data() {
            return {
                newsList: [],
                newsInfo: [],
                id: this.$route.params.id
            }
        },
        created() {
            this.getNewsInfo();
        },
        methods: {
            getNewsInfo() {
                this.$http.get('public/images/data.json').then(result => {
                    if (result.body.status == 0) {
                        this.newsList = result.body.message[this.id-1];
                        this.newsInfo = result.body.novel[0];

                        console.log(result.body.novel);
                       // console.log(this.newsInfo);
                    } else {
                        Toast('获取新闻详情失败');
                    }
                });
            }
        },
        //注册子组件
        components:{
        "comment-box":comment
        }
    }
</script>

<style lang="less" >
// 不加scoped 指定 .newsinfo-container容器就不会产生样式全局化
    .newsinfo-container {
        padding: 0 5px;

        .title {
            font-size: 16px;
            text-align: center;
            margin: 15px 0;
        }

        .subtitle {
            font-size: 13px;
            color: rgb(54, 158, 239);
            display: flex;
            justify-content: space-between
        }

        .content {
            img{
                width: 100%;
            }
        }
    }
</style>